<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    var p1 = {
      name: "张三",
      tel: function (callName, time) {
        //为p1增加一个方法tel
        console.log(this.name + "给" + callName + "打" + time + "分钟电话");
        console.log(this); //通过call被p2调用时指向p2
      },
    };
    /* p1.tel = function (callName,time) {
      //为p1增加一个方法tel
      console.log(this.name + "给"+callName+"打"+time+"分钟电话");
      console.log(this); //通过call被p2调用时指向p2
    }; */
    var p2 = {  
      name: "王老五",
    };
    p1.tel("李四", 12);
    p1.tel.call(p2, "李四", 12); //call 参数不需要加[]
    p1.tel.apply(p2, ["李四", 12]); //apply 传参要用为数组[]
  </script>
</html>
